package de.andreavicentini.teatralia.generate;

import org.magiclabs.htmlx.*;
import de.andreavicentini.teatralia.pages.members.*;
import java.util.*;

public class Members implements ITransfx {
  protected static String nl;
  public static synchronized Members create(String lineSeparator)
  {
    nl = lineSeparator;
    Members result = new Members();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = NL + NL + "<p class=\"intro\">";
  protected final String TEXT_3 = "</p>" + NL;
  protected final String TEXT_4 = NL;
  protected final String TEXT_5 = NL + "<table><tr><td>" + NL + "<img src=\"images/";
  protected final String TEXT_6 = ".jpg\" width=120>" + NL + "</td>" + NL + " <td>" + NL + "<p>" + NL + " <em>";
  protected final String TEXT_7 = NL;
  protected final String TEXT_8 = ", ";
  protected final String TEXT_9 = ", ";
  protected final String TEXT_10 = " ";
  protected final String TEXT_11 = NL + "</em>" + NL + "</p>" + NL + "<p>";
  protected final String TEXT_12 = NL + "</td>" + NL + "</tr></table></div><p>" + NL;

	public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
      
MembersPage page = (MembersPage) argument;

    stringBuffer.append(TEXT_2);
    stringBuffer.append( page.getText(MembersPage.Keys.intro) );
    stringBuffer.append(TEXT_3);
     for (Member member : page.iterateMembers()) { 
    stringBuffer.append(TEXT_4);
    stringBuffer.append( new ToggleHeader(member.getImage(), member.getFirstName() + " " + member.getLastName()) );
    stringBuffer.append(TEXT_5);
    stringBuffer.append( member.getImage() );
    stringBuffer.append(TEXT_6);
    stringBuffer.append(TEXT_7);
    stringBuffer.append( member.getRole() );
    stringBuffer.append(TEXT_8);
    stringBuffer.append( member.getNationality() );
    stringBuffer.append(TEXT_9);
    stringBuffer.append( member.getBornIn() );
    stringBuffer.append(TEXT_10);
    stringBuffer.append( member.getCity() );
    stringBuffer.append(TEXT_11);
    stringBuffer.append( page.getText(member.getDescription()) );
    stringBuffer.append(TEXT_12);
     } 
    return stringBuffer.toString();
  }
}